﻿namespace Sidvall.WorkItemManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class IdentityProvider : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.WorkItemManager.Data.IIdentityProvider
    {
        #region Public Members

        #region IdentityProviderId

        private System.Nullable<int> _IdentityProviderId;
        partial void OnBeforeIdentityProviderIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterIdentityProviderIdPropertyChanged();
        public System.Nullable<int> IdentityProviderId
        { 
            get
            {
                return _IdentityProviderId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IdentityProviderId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _IdentityProviderId);
                    OnBeforeIdentityProviderIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IdentityProviderId", eventData.Value, true, true);
                        OnAfterIdentityProviderIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region Password

        private string _Password;
        partial void OnBeforePasswordPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterPasswordPropertyChanged();
        public string Password
        { 
            get
            {
                return _Password;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Password = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Password);
                    OnBeforePasswordPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Password", eventData.Value, true, true);
                        OnAfterPasswordPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region STSAddress

        private string _STSAddress;
        partial void OnBeforeSTSAddressPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSTSAddressPropertyChanged();
        public string STSAddress
        { 
            get
            {
                return _STSAddress;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _STSAddress = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _STSAddress);
                    OnBeforeSTSAddressPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("STSAddress", eventData.Value, true, true);
                        OnAfterSTSAddressPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region STSClientId

        private string _STSClientId;
        partial void OnBeforeSTSClientIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSTSClientIdPropertyChanged();
        public string STSClientId
        { 
            get
            {
                return _STSClientId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _STSClientId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _STSClientId);
                    OnBeforeSTSClientIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("STSClientId", eventData.Value, true, true);
                        OnAfterSTSClientIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region STSClientSecret

        private string _STSClientSecret;
        partial void OnBeforeSTSClientSecretPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSTSClientSecretPropertyChanged();
        public string STSClientSecret
        { 
            get
            {
                return _STSClientSecret;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _STSClientSecret = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _STSClientSecret);
                    OnBeforeSTSClientSecretPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("STSClientSecret", eventData.Value, true, true);
                        OnAfterSTSClientSecretPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region UserName

        private string _UserName;
        partial void OnBeforeUserNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterUserNamePropertyChanged();
        public string UserName
        { 
            get
            {
                return _UserName;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _UserName = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _UserName);
                    OnBeforeUserNamePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("UserName", eventData.Value, true, true);
                        OnAfterUserNamePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public IdentityProvider Copy()
        {
            return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Copy(this);
        }
        public IdentityProvider Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.WorkItemManager.Data.IIdentityProvider item)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Import(this, item);
        }
        public void Import(global::Sidvall.WorkItemManager.Data.IIdentityProvider item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Import(this, item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Initialize(this, settings);
        }

        #endregion

        #region IIdentityProvider Members

        System.Nullable<int> global::Sidvall.WorkItemManager.Data.IIdentityProvider.IdentityProviderId
        {
            get
            {
                return this._IdentityProviderId;
            }
            set
            {
                this._IdentityProviderId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IIdentityProvider.Password
        {
            get
            {
                return this._Password;
            }
            set
            {
                this._Password = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IIdentityProvider.STSAddress
        {
            get
            {
                return this._STSAddress;
            }
            set
            {
                this._STSAddress = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IIdentityProvider.STSClientId
        {
            get
            {
                return this._STSClientId;
            }
            set
            {
                this._STSClientId = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IIdentityProvider.STSClientSecret
        {
            get
            {
                return this._STSClientSecret;
            }
            set
            {
                this._STSClientSecret = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IIdentityProvider.UserName
        {
            get
            {
                return this._UserName;
            }
            set
            {
                this._UserName = value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public IdentityProvider()
        {
        }
        public IdentityProvider(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public IdentityProvider(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.IdentityProviderManager.Initialize(this);
        }

        #endregion
    }
}